package com.example.exceldemo.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.service.VendorExtension;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

/**
 * @Author: yanhongwei
 * @Date: 2023/07/13 14:45:45
 * @Description: TODO 自定义swagger配置信息
 */

@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket docket(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .enable(true)
                .groupName("yhw")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.example.exceldemo.controller"))
                .paths(PathSelectors.ant("/**"))
                .build();
    }

    public ApiInfo apiInfo(){
        Contact contact = new Contact("yhw","www.zhangsan.com","22222@qq.com");
        return new ApiInfo(
                "zhangsan's api",
                "this is description",
                "v1.0",
                "2222@qq.com",
                contact,
                "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList<VendorExtension>()
        );
    }
}
